<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <title><!--{$lang.page.index.title}--></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/lay/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/lay/layui/index.css" media="all">
  <style rel="stylesheet">
      .layui-unselect {
          height: 30px;
      }
  </style>
</head>
<body>
  <div class="layui-card">
    <div class="layui-tab layui-tab-brief layadmin-latestData">
        <ul class="layui-tab-title">
            <li <!--{if empty($action) || $action=='recharge'}-->class="layui-this"<!--{/if}-->><!--{$lang.page.table.cashin}--></li>
            <li <!--{if $action=='withdraw'}-->class="layui-this"<!--{/if}-->><!--{$lang.page.table.withdrawal}--></li>
        </ul>
        <div class="layui-tab-content">
            <div <!--{if empty($action) || $action=='recharge'}-->class="layui-tab-item layui-show"<!--{else}-->class="layui-tab-item"<!--{/if}-->>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label" style="text-align: left; min-width: auto"><!--{$lang.page.table.account}--></label>
                        <div class="layui-input-inline">
                            <input type="text" id="username" name="username" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label" ><!--{$lang.page.table.time}--></label>
                        <div class="layui-input-inline">
                            <input id="retimerange" type="text" name="retimerange" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="research">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                        </button>
                    </div>
                </div>

                <table id="recharge" lay-filter="recharge"></table>
                <script type="text/html" id="rechargetop">
                    <button class="layui-btn layui-btn-sm" lay-event="rerecharge"><!--{$lang.page.public.refresh}--></button>
                    <button class="layui-btn layui-btn-sm" id="rall" lay-event="all"><!--{$lang.page.table.all}--></button>
                    <button class="layui-btn layui-btn-sm" id="rday" lay-event="day"><!--{$lang.page.table.today}--></button>
                    <button class="layui-btn layui-btn-sm" id="rweek" lay-event="week"><!--{$lang.page.table.toweek}--></button>
                    <button class="layui-btn layui-btn-sm" id="rmonth" lay-event="month"><!--{$lang.page.table.tomonth}--></button>
                    <div class="layui-inline layui-btn-sm">
                        <select name="method" id="method" class="layui-unselect" lay-filter="brickType">
                            <option value="0"><!--{$lang.page.public.select}--></option>
                            <option value="1"><!--{$lang.page.table.online}--></option>
                            <option value="2"><!--{$lang.page.table.noauto}--></option>
                        </select>
                    </div>
                    <div class="layui-btn layui-btn-green layui-btn-sm" id="currency"></div>
                    <div class="layui-btn layui-btn-green layui-btn-sm" id="moneysum"></div>
                    <div class="layui-btn layui-btn-green layui-btn-sm" id="integra"></div> 
                </script>
            </div>

            <div <!--{if $action=='withdraw'}-->class="layui-tab-item layui-show"<!--{else}-->class="layui-tab-item"<!--{/if}-->>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label" style="text-align: left; min-width: auto"><!--{$lang.page.table.account}--></label>
                        <div class="layui-input-inline">
                            <input type="text" id="wdusername" name="wdusername" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label" ><!--{$lang.page.table.time}--></label>
                        <div class="layui-input-inline">
                            <input id="wdtimerange" type="text" name="wdtimerange" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="wdsearch">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                        </button>
                    </div>
                </div>
                <script type="text/html" id="zizeng">{{d.LAY_TABLE_INDEX+1}}</script>
                <table id="withdrawlist"  lay-filter="withdrawlist"></table>
                <script type="text/html" id="withdrawtop">
                    <div class="layui-btn-container">
                        <button class="layui-btn layui-btn-sm" lay-event="rewithdraw"><!--{$lang.page.public.refresh}--></button>
                        <button class="layui-btn layui-btn-sm" id="all" lay-event="all"><!--{$lang.page.table.all}--></button>
                        <button class="layui-btn layui-btn-sm" id="day" lay-event="day"><!--{$lang.page.table.today}--></button>
                        <button class="layui-btn layui-btn-sm" id="week" lay-event="week"><!--{$lang.page.table.toweek}--></button>
                        <button class="layui-btn layui-btn-sm" id="month" lay-event="month"><!--{$lang.page.table.tomonth}--></button>
                        <div class="layui-btn layui-btn-green layui-btn-sm" id="dcurrency"></div>
                        <div class="layui-btn layui-btn-green layui-btn-sm" id="dmoney"></div>
                        <div class="layui-btn layui-btn-green layui-btn-sm" id="dintegra"></div> 
                        <div class="layui-btn layui-btn-green layui-btn-sm" id="dfee"></div>
                        <div class="layui-btn layui-btn-green layui-btn-sm" id="dzhifu"></div>   
                    </div>
                </script>
            </div>
        </div>
    </div>
</div>
<script src="/static/lay/layui/layui.js"></script>
<script type="text/javascript">
    layui.config({
       base: '/static/lay/' //静态资源所在路径
    }).extend({
         roleper:'lib/roleper'
         , xadmin:'lib/xadmin'
         , lang:'lib/lang'
         , time:'lib/time'
    }).use(['roleper', 'xadmin', 'table', 'laydate','form', 'lang', 'time'], function () {
            var $ = layui.$
            , form = layui.form
            , laydate = layui.laydate
            , table = layui.table
            , roleper = layui.roleper
            , toolbar = roleper.showtool({mid:29}) ? false : true; //根据权限是否显示操作列
            var lang=layui.lang.init();
            var time=layui.time;
            table.render({
            elem: '#withdrawlist'
            , height: 'auto'
            , url: 'mwithdraw' //数据接口
            , method: 'post'
            , page: true //开启分页
            , limit: 10
            , toolbar: '#withdrawtop'
            , defaultToolbar: ['filter', 'exports', 'print']
            , cols: [[ //表头
                {field: 'zizeng', title: function(){ return lang.serial }, align: "center", fixwidth: true, width: 80, templet:'#zizeng'},
                {field: 'username', title: function(){ return lang.account }},
                {field: 'realname', title: function(){ return lang.realname }},
                {field: 'currency', title: function(){ return lang.cashout+lang.curtype}},
                {field: 'money', title: function(){ return lang.cashout+lang.money }},
                {field: 'integra', title: function(){ return lang.cashout+lang.give+lang.money }},
                {field: 'fee', title: function(){ return lang.fee }},
                {field: 'payaction', title: function(){ return lang.payaction+lang.money },
                    templet: function(d) {
                       if (d.money > 0) {
                            return (d.money-d.fee);
                        } else{
                            return 0.00;
                        }
                    }
                },
                {field: 'codes', title: function(){ return lang.exchange+lang.curtype}},
                {field: 'remoney', title: function(){ return lang.exchange+lang.cashout+lang.money }},
                {field: 'reintegra', title: function(){ return lang.exchange+lang.give+lang.money }},
                {field: 'createtime', title: function(){ return lang.createtime }},
                {field: 'status', title: function(){ return lang.status},
                 templet: function(d) {
                       if (d.status == 1) {
                            return '<button class="layui-btn layui-btn-danger layui-btn-xs">'+lang.applying+'</button>';
                        } else if(d.status == 2) {
                            return '<button class="layui-btn layui-btn-primary layui-btn-xs">'+lang.gback+'</button>';
                        } else if(d.status == 3) {
                            return '<button class="layui-btn layui-btn-green layui-btn-xs">'+lang.pass+'</button>';
                        } else if(d.status == 4) {
                            return '<button class="layui-btn layui-btn-primary layui-btn-xs">'+lang.finish+'</button>';
                        }
                  }
                },
                // {fixed: '', title: '操作', width: 160, align: 'center', toolbar: '#withdrawlistbar', hide:toolbar}
            ]],
            done: function(d) {
                layer.closeAll('loading');
                $('#dmoney').html(lang.cashout+lang.total+"："+(d.money).toFixed(2)); // 更新总计内容
                $('#dintegra').html(lang.give+lang.cashout+lang.total+"："+(d.integra).toFixed(2)); // 更新总计内容
                $('#dcurrency').html(lang.curtype+"："+(d.currency)); // 更新总计内容
                $('#dfee').html(lang.fee+lang.total+"："+(d.fee).toFixed(2)); // 更新总计内容
                $('#dzhifu').html(lang.payaction+lang.total+"："+(d.money-d.fee).toFixed(2)); // 更新总计内容
                // roleper.render({mid:27,per:[{sys:'pay',method:'open'}],full:false});//law 设置长宽，full是否全屏，par父窗口打开
            }
            });
            table.render({
            elem: '#recharge'
            , height: 'auto'
            , url: 'mrechargelist' //数据接口
            , method: 'post'
            , page: true //开启分页
            , limit: 10
            , toolbar: '#rechargetop'
            , defaultToolbar: ['filter', 'exports', 'print']
            , cols: [[ //表头
                {field: 'zizeng', title: function(){ return lang.serial }, align: "center", fixwidth: true, width: 80, templet:'#zizeng'},
                {field: 'username', title: function(){ return lang.account }},
                {field: 'realname', title: function(){ return lang.realname }},
                {field: 'currency', title: function(){ return lang.cashin+lang.curtype}},
                {field: 'money', title: function(){ return lang.cashin+lang.money }},
                {field: 'integra', title: function(){ return lang.give+lang.money }},
                {field: 'codes', title: function(){ return lang.exchange+lang.curtype}},
                {field: 'remoney',  title: function(){ return lang.exchange+lang.money}},
                {field: 'reintegra',  title: function(){ return lang.exchange+lang.give+lang.money}},
                {field: 'rate', title: function(){ return lang.exrate}},
                {field: 'type', title: function(){ return lang.type },
                 templet: function(d) {
                       if (d.type == 1) {
                            return '<button class="layui-btn layui-btn-danger layui-btn-xs">'+lang.tradeing+'</button>';
                        } else if(d.type == 2) {
                            return '<button class="layui-btn layui-btn-xs">'+lang.virtual+'</button>';
                        } 
                  }
                },
                {field: 'method', title: function(){ return lang.method },
                 templet: function(d) {
                       if (d.method == 1) {
                            return '<button class="layui-btn layui-btn-green layui-btn-xs">'+lang.online+'</button>';
                        } else if(d.method == 2) {
                            return '<button class="layui-btn layui-btn-danger layui-btn-xs">'+lang.noauto+'</button>';
                        } 
                  }
                },
                {field: 'createtime', title: function(){ return lang.createtime }},
                {field: 'status', title: function(){ return lang.status},
                 templet: function(d) {
                       if (d.status == 1) {
                            return '<button class="layui-btn layui-btn-danger layui-btn-xs">'+lang.applying+'</button>';
                        } else if(d.status == 2) {
                            return '<button class="layui-btn layui-btn-xs">'+lang.gback+'</button>';
                        } else if(d.status == 3) {
                            return '<button class="layui-btn layui-btn-green layui-btn-xs">'+lang.pass+'</button>';
                        }
                  }
                },
                // {fixed: '', title: '操作', width: 160, align: 'center', toolbar: '#rechargebar', hide:toolbar}
            ]],
            done: function(d) {
                layer.closeAll('loading');
                $('#moneysum').html(lang.cashin+lang.total+"："+(d.money).toFixed(2)); // 入金总计
                $('#integra').html(lang.give+lang.total+"："+(d.integra).toFixed(2)); // 赠送总计
                $('#currency').html(lang.curtype+"："+(d.currency)); // 赠送总计
                // roleper.render({mid:27,per:[{sys:'recharge',method:'open'},{sys:'redit',method:'open'}],full:false});//law 设置长宽，full是否全屏，par父窗口打开
            }
            });
            let nowtime=new Date();
            laydate.render({
                type: 'date'
                ,elem: '#retimerange'
                ,range: '~'
                ,max:time.getnowdate()
            });
            laydate.render({
                type: 'date'
                ,elem: '#wdtimerange'
                ,range: '~'
                ,max:time.getnowdate()
            });
            form.on('select(brickType)', function(data){
                table.reload('recharge',{
                  where: {'method':data.value},
                  page: {
                    curr: 1 //重新从第 1 页开始
                  }
                });
                $("#method").val(data.value);
            });
            //监听搜索
            form.on('submit(research)', function(){
                var retimerange = $("#retimerange").val();
                var username = $("#username").val();
                //执行重载
                table.reload('recharge', {
                    where: {'retimerange':retimerange, 'username':username}
                });
            });
            //监听搜索
            form.on('submit(wdsearch)', function(){
                var retimerange = $("#wdtimerange").val();
                var username = $("#wdusername").val();
                //执行重载
                table.reload('withdrawlist', {
                    where: {'wdretimerange':retimerange, 'wdusername':username}
                });
            });
            table.on('toolbar(withdrawlist)', function(obj){
                var element = $(".layui-btn-draw").attr("id");
                switch(obj.event){
                    case 'rewithdraw':
                        //执行重载
                        table.reload('withdrawlist');
                        $('#'+element).addClass('layui-btn-danger layui-btn-draw')
                    break;
                    case 'all':
                        //执行重载
                        table.reload('withdrawlist', {
                            where: {},
                            page: {
                              curr: 1 //重新从第 1 页开始
                            }
                        });
                        $('#all').addClass('layui-btn-danger layui-btn-draw')
                    break;
                    case 'day':
                        //执行重载
                        table.reload('withdrawlist', {
                            where: {'time':1},
                            page: {
                              curr: 1 //重新从第 1 页开始
                            }
                        });
                        $('#day').addClass('layui-btn-danger layui-btn-draw')
                    break;
                    case 'week':
                        //执行重载
                        table.reload('withdrawlist', {
                            where: {'time':2},
                            page: {
                              curr: 1 //重新从第 1 页开始
                            }
                        });
                        $('#week').addClass('layui-btn-danger layui-btn-draw')
                    break;
                    case 'month':
                        //执行重载
                        table.reload('withdrawlist', {
                            where: {'time':3},
                            page: {
                              curr: 1 //重新从第 1 页开始
                            }
                        });
                        $('#month').addClass('layui-btn-danger layui-btn-draw')
                    break;
                };
            });
            table.on('toolbar(recharge)', function(obj){
                var element = $(".layui-btn-rech").attr("id");
                var method = $("#method option:selected").val();
                switch(obj.event){
                    case 'rerecharge':
                        //执行重载
                        table.reload('recharge');
                        $('#'+element).addClass('layui-btn-danger layui-btn-rech')
                    break;
                    case 'all':
                        //执行重载
                        table.reload('recharge', {
                            where: {'method':method},
                            page: {
                              curr: 1 //重新从第 1 页开始
                            }
                        });
                        $("#method").val(method);
                        $('#rall').addClass('layui-btn-danger layui-btn-rech')
                    break;
                    case 'day':
                        //执行重载
                        table.reload('recharge', {
                            where: {'method':method, 'time':1},
                            page: {
                              curr: 1 //重新从第 1 页开始
                            }
                        });
                        $("#method").val(method);
                        $('#rday').addClass('layui-btn-danger layui-btn-rech')
                    break;
                    case 'week':
                        //执行重载
                        table.reload('recharge', {
                            where: {'method':method, 'time':2},
                            page: {
                              curr: 1 //重新从第 1 页开始
                            }
                        });
                        $("#method").val(method);
                        $('#rweek').addClass('layui-btn-danger layui-btn-rech')
                    break;
                    case 'month':
                        //执行重载
                        table.reload('recharge', {
                            where: {'method':method, 'time':3},
                            page: {
                              curr: 1 //重新从第 1 页开始
                            }
                        });
                        $("#method").val(method);
                        $('#rmonth').addClass('layui-btn-danger layui-btn-rech')
                    break;
                };
            }); 
    });
</script>
</body>
</html>